package com.cqie.teacherserver.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cqie.campuscommon.result.Result;
import com.cqie.teacherserver.entity.TeacherTeachingStatistics;
import com.cqie.teacherserver.mapper.TeacherTeachingStatisticsMapper;
import com.cqie.teacherserver.service.ITeacherTeachingStatisticsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 教学统计信息(按老师) 服务实现类
 * </p>
 *
 * @author zhangr132
 * @since 2024-05-31
 */
@Slf4j
@Service
public class TeacherTeachingStatisticsServiceImpl extends ServiceImpl<TeacherTeachingStatisticsMapper, TeacherTeachingStatistics> implements ITeacherTeachingStatisticsService {

    @Autowired
    private TeacherTeachingStatisticsMapper teacherTeachingStatisticsMapper;

    @Override
    public Result getTeacherCourseInfo(String teacherCode) {
        log.info("正在处理教师授课信息获取请求");

        QueryWrapper<TeacherTeachingStatistics> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda()
                .eq(TeacherTeachingStatistics::getXgh, teacherCode);
        TeacherTeachingStatistics teacherTeachingStatistics = this.getOne(queryWrapper);
        if(teacherTeachingStatistics != null){
            log.info("教师授课信息："+teacherTeachingStatistics);
            return Result.Success(teacherTeachingStatistics);
        }

        log.error("教师授课信息获取失败");
        return Result.Failed("教师授课信息获取失败");
    }
}
